#include	"interrupt.h"
#include	"can.h"

u16	F_Time_100us  = 0;
u16	F_Time_1ms    = 0;
u16	F_Time_2ms    = 0;
u16	F_Time_10ms   = 0;
u16	F_Time_33ms   = 0;
u16	F_Time_50ms   = 0;
u16	F_Time_400ms  = 0;
u16	F_Time_500ms  = 0;
u16	F_Time_100ms  = 0;
u16	F_Time_1000ms = 0;
u16	F_Time_1Min   = 0;

u16	T_1MS_Cnt    = 10;
u16	T_2MS_Cnt    = 2;
u16	T_10MS_Cnt   = 10;
u16	T_33MS_Cnt   = 33;
u16	T_50MS_Cnt   = 5;
u16	T_100MS_Cnt  = 10;
u16	T_400MS_Cnt  = 40;
u16	T_500MS_Cnt  = 50;
u16	T_1000MS_Cnt = 100;
u16	T_1Min_Cnt   = 60;

//************************************************************************************
//	Interrupt routine Multi
//************************************************************************************

void ISR_TM2(void)
{
	F_Time_100us = 1;
	T_1MS_Cnt--;
	if(T_1MS_Cnt == 0)
	{
		T_1MS_Cnt = 10;
		F_Time_1ms = 1;							//1ms flag
		
		T_2MS_Cnt--;
		if(T_2MS_Cnt == 0)
		{
			T_2MS_Cnt = 2;
			F_Time_2ms = 1;
		}
		
		T_33MS_Cnt--;
		if(T_33MS_Cnt == 0) 			//20ms
		{
			T_33MS_Cnt = 33;
			F_Time_33ms = 1;
		}
		T_10MS_Cnt--;
		if(T_10MS_Cnt == 0)
		{
			T_10MS_Cnt = 10;
			F_Time_10ms = 1;					//10ms flag
			T_50MS_Cnt--;
			if(T_50MS_Cnt == 0) 			//50ms
			{
				T_50MS_Cnt = 5;
				F_Time_50ms = 1;
			}
			T_100MS_Cnt--;
			if(T_100MS_Cnt == 0) 			//100ms
			{
				T_100MS_Cnt = 10;
				F_Time_100ms = 1;
			}
			T_400MS_Cnt--;
			if(T_400MS_Cnt == 0)
			{
				T_400MS_Cnt = 20;
				F_Time_400ms = 1;				//400ms flag
			}
			T_500MS_Cnt--;
			if(T_500MS_Cnt == 0)
			{
				T_500MS_Cnt = 50;
				F_Time_500ms = 1;				//500ms flag
			}
			T_1000MS_Cnt--;
			if(T_1000MS_Cnt == 0)
			{
				T_1000MS_Cnt = 100;
				F_Time_1000ms = 1;		 //1s flag
				
				T_1Min_Cnt--;
				if(T_1Min_Cnt == 0)
				{
					T_1Min_Cnt = 60;
					F_Time_1Min = 1;		 //60s flag
				}
				if(CAN1_AircdRxResetTime1)
					CAN1_AircdRxResetTime1--;
				if(CAN1_AircdRxResetTime2)
					CAN1_AircdRxResetTime2--;
				if(CAN2_AircdRxResetTime1)
					CAN2_AircdRxResetTime1--;
				if(CAN2_AircdRxResetTime2)
					CAN2_AircdRxResetTime2--;
			}
		}
	}
}


